Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add FasterRouteDetector to check for quicker routes while navigating #638

Merged
merged 19 commits into from
Jan 19, 2018

Conversation

danesfeder
Copy link
Contributor

Closes #129

  • Adds FasterRouteDetector and RouteEngine to check for / retrieve faster routes while navigating
  • FasterRoute can be subclassed to allow users to set exactly how quickly they'd like to check for a new, possibly faster route.
  • Also adds the ability to provide RouteOptions to NavigationRoute to create a route request mirroring the options from the DirectionsRoute that provided the RouteOptions

cc @ericrwolfe

@danesfeder danesfeder added this to the v0.9.0 milestone Jan 8, 2018
@danesfeder danesfeder self-assigned this Jan 8, 2018
private Location lastCheckedLocation;

@Override
public boolean shouldCheckFasterRoute(Location location, RouteProgress routeProgress) {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@mapbox/navigation-ios When you have a chance, can I get some 👀 on shouldCheckFasterRoute and isFasterRoute? The former determines when a new route request should fire, while the latter determines if the DirectionsRoute from the response is actually faster the current route. Thanks!

double currentDurationRemaining = routeProgress.durationRemaining();
DirectionsRoute newRoute = response.routes().get(0);

if (hasLegs(newRoute)) {
Copy link

@bsudekum bsudekum Jan 10, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

}
// Check if the faster route time interval has been exceeded
if (secondsSinceLastCheck(location) > NAVIGATION_CHECK_FASTER_ROUTE_INTERVAL) {
lastCheckedLocation = location;

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should this only be set if the function returns true? If so, it needs to be moved into the next if statement.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

secondsSinceLastCheck() returns the how long in seconds it's been since lastCheckedLocation, so after two min, this will be set and essentially reset the timer

@danesfeder danesfeder force-pushed the dan-faster-route branch 3 times, most recently from 15a7d62 to 5340c28 Compare January 17, 2018 15:35
this.routeProgress = routeProgress;

// Calculate remaining waypoints
List<Point> coordinates = new ArrayList<>(routeProgress.directionsRoute().routeOptions().coordinates());
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@ericrwolfe starting with this line, does this logic make sense? I've tested with multi-waypoint / origin + destination routes and is seems to be working fine

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hrmm, @bsudekum might be a better person to review this logic. I'm not as versed on how we deal with multiple waypoints.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@bsudekum RouteOptions#coordinates represents the list of points making up the route. This would be equivalent to your list of legs with destinations (which we currently don't have on Android)

@danesfeder danesfeder removed the ⚠️ DO NOT MERGE PR should not be merged! label Jan 19, 2018
@danesfeder danesfeder merged commit 471601d into master Jan 19, 2018
@danesfeder danesfeder deleted the dan-faster-route branch January 19, 2018 23:36
@danesfeder danesfeder mentioned this pull request Jan 23, 2018
14 tasks
TranThuong pushed a commit to TranThuong/mapbox-navigation-android that referenced this pull request Jan 26, 2018
* master:
  Update Strings with Transifex Translations (mapbox#657)
  Added embedded navigation example (mapbox#654)
  Release 0.9.0 (mapbox#663)
  Update README.md for 0.9.0 (mapbox#664)
  Add Maneuver type exit rotary constant (mapbox#653)
  Update Maps and Services dependencies  (mapbox#661)
  Add FasterRouteDetector to check for quicker routes while navigating  (mapbox#638)
  Directions API Banner instructions (mapbox#582)
  NavigationTelemetry update cue for changing configurations (mapbox#648)
  Moved WaypointNavigationActivity from the SDK to the test app (mapbox#652)
  Exposes the MapboxMap in NavigationView with a getter method (mapbox#642)
  Add language to NavigationViewOptions with default from RouteOptions (mapbox#635)

# Conflicts:
#	libandroid-navigation/src/main/java/com/mapbox/services/android/navigation/v5/navigation/NavigationEngine.java
#	libandroid-navigation/src/main/java/com/mapbox/services/android/navigation/v5/navigation/NavigationService.java
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants